package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.JwPartyRecommendat;
import com.ruoyi.system.service.IJwPartyRecommendatService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 推优人员Controller
 * 
 * @author ruoyi
 * @date 2024-11-06
 */
@RestController
@RequestMapping("/system/recommendat")
public class JwPartyRecommendatController extends BaseController
{
    @Autowired
    private IJwPartyRecommendatService jwPartyRecommendatService;

    /**
     * 查询推优人员列表
     */
    @PreAuthorize("@ss.hasPermi('system:recommendat:list')")
    @GetMapping("/list")
    public TableDataInfo list(JwPartyRecommendat jwPartyRecommendat)
    {
        startPage();
        List<JwPartyRecommendat> list = jwPartyRecommendatService.selectJwPartyRecommendatList(jwPartyRecommendat);
        return getDataTable(list);
    }

    /**
     * 导出推优人员列表
     */
    @PreAuthorize("@ss.hasPermi('system:recommendat:export')")
    @Log(title = "推优人员", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, JwPartyRecommendat jwPartyRecommendat)
    {
        List<JwPartyRecommendat> list = jwPartyRecommendatService.selectJwPartyRecommendatList(jwPartyRecommendat);
        ExcelUtil<JwPartyRecommendat> util = new ExcelUtil<JwPartyRecommendat>(JwPartyRecommendat.class);
        util.exportExcel(response, list, "推优人员数据");
    }

    /**
     * 获取推优人员详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:recommendat:query')")
    @GetMapping(value = "/{prId}")
    public AjaxResult getInfo(@PathVariable("prId") Long prId)
    {
        return success(jwPartyRecommendatService.selectJwPartyRecommendatByPrId(prId));
    }

    /**
     * 新增推优人员
     */
    @PreAuthorize("@ss.hasPermi('system:recommendat:add')")
    @Log(title = "推优人员", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody JwPartyRecommendat jwPartyRecommendat)
    {
        return toAjax(jwPartyRecommendatService.insertJwPartyRecommendat(jwPartyRecommendat));
    }

    /**
     * 修改推优人员
     */
    @PreAuthorize("@ss.hasPermi('system:recommendat:edit')")
    @Log(title = "推优人员", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody JwPartyRecommendat jwPartyRecommendat)
    {
        return toAjax(jwPartyRecommendatService.updateJwPartyRecommendat(jwPartyRecommendat));
    }

    /**
     * 删除推优人员
     */
    @PreAuthorize("@ss.hasPermi('system:recommendat:remove')")
    @Log(title = "推优人员", businessType = BusinessType.DELETE)
	@DeleteMapping("/{prIds}")
    public AjaxResult remove(@PathVariable Long[] prIds)
    {
        return toAjax(jwPartyRecommendatService.deleteJwPartyRecommendatByPrIds(prIds));
    }
}
